package com.tj.tj_java.mapper;

import com.tj.tj_java.dto.DanmuDto;
import com.tj.tj_java.pojo.Danmu;
import com.tj.tj_java.pojo.Video;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface VideoMapper {

    //获取全部音乐的数据
    @Select("select * from videos")
    List<Video> selectAllVideo();

    //根据视频id获取该视频数据
    @Select("select * from videos where videoId = #{videoId}")
    Video selectVideoById(int videoId);

    //根据视频id获取该视频的弹幕
    @Select("select * from danmus where videoId = #{videoId}")
    List<Danmu> selectDanmuByVideoId(int videoId);

    //添加一条弹幕
    @Insert("insert into danmus (userId, videoId, danmuText, danmuTime, danmuColor, danmuBorder, danmuMode) values (#{userId},#{videoId},#{text},#{time},#{color},#{border},#{mode})")
    void addDanmu(int userId,int videoId,String text,double time,String color,boolean border,int mode);
}
